package character;

import java.util.ArrayList;

/**
 * Family.
 * @author pcdejager
 */
public final class Family {
    /**
     * Create a family class with no parents.
     * @return The empty family class
     */
    public static Family create() {
        return new Family(null);
    }
    /**
     * Create a family class with given father and mother.
     * @param f The father (Gender must be MALE)
     * @param m The mother (Gender must be FEMALE)
     * @return The family class
     */
    public static Family create(final Character f, final Character m) {
        return new Family(Parents.create(f, m));
    }
    /**
     * Check if parents exist.
     * @return True if has parents, else false.
     */
    public boolean hasParents() {
        return (parents != null);
    }
    /**
     * Get the parents.
     * @return The parents
     */
    public Parents getParents() {
        return parents;
    }
    /**
     * Add a sibling.
     * @param c The sibling to add
     */
    public void addSibling(final Character c) {
        siblings.add(c);
    }
    /**
     * Get the number of siblings.
     * @return The number
     */
    public int getNumberOfSiblings() {
        return siblings.size();
    }
    /**
     * Get the sibling at an index.
     * @param index The index
     * @return The sibling
     */
    public Character getSibling(final int index) {
        if ((index < 0) || (index >= siblings.size())) {
            return null;
        }
        return siblings.get(index);
    }
    /**
     * Private constructor.
     * @param p The parents
     */
    private Family(final Parents p) {
        parents = p;
        siblings = new ArrayList<Character>();
    }
    /**
     * The parents.
     */
    private final Parents parents;
    /**
     * The siblings.
     */
    private ArrayList<Character> siblings;
}
